﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using TalentRecruitmentSystem.Manage;
using TalentRecruitmentSystem.Service;
using System.Data;

namespace TalentRecruitmentSystem.Pages
{
    public partial class TalentsSearch : System.Web.UI.Page
    {
        CompanyInfoManage cm = new CompanyInfoManage();
        UserInfoManage um = new UserInfoManage();
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        private void Bind2()
        {
            string s1 = DropDownList1.Text;
            string s2 = DropDownList2.Text;
            string s3 = DropDownList3.Text;
            List<UserInfo> list = um.GetUserInfosByParameter(s1, s2, s3);
            DataTable dt = new DataTable();
            dt.Columns.Add("TrueName");
            dt.Columns.Add("Profession");
            dt.Columns.Add("ProfessionDescribe");
            dt.Columns.Add("Workexperience");
            dt.Columns.Add("Languagelevel");
            dt.Columns.Add("Phone");
            foreach (UserInfo u in list)
            {
                dt.Rows.Add(u.TruthName, u.Profession, u.ProfessionDescribe, u.Workexperience, u.Languagelevel, u.Phone);
            }
            GridView1.DataSource = dt;
        }
        private void Bind1()
        {
            CompanyInfo companyInfo = new CompanyInfo();
            if (Session["comInSession"] != null & Session["comInSession"] != "")
            {
                companyInfo = cm.getCompanyInfoByUserName(Session["comInSession"].ToString());
            }
            UserInfo userInfo = new UserInfo();
            List<UserInfo> list = new List<UserInfo>();
            if (companyInfo != null & companyInfo.Jobhunter != null)
            {
                string[] str = companyInfo.Jobhunter.Split(',');
                foreach (string s in str)
                {
                    userInfo = um.getUserInfoByUserName(s);
                    list.Add(userInfo);
                }
                DataTable dt = new DataTable();
                dt.Columns.Add("TrueName");
                dt.Columns.Add("Profession");
                dt.Columns.Add("ProfessionDescribe");
                dt.Columns.Add("Workexperience");
                dt.Columns.Add("Languagelevel");
                dt.Columns.Add("Phone");
                foreach (UserInfo u in list)
                {
                    dt.Rows.Add(u.TruthName, u.Profession, u.ProfessionDescribe, u.Workexperience, u.Languagelevel, u.Phone);
                }
                GridView1.DataSource = dt;
            }
            else
            {
                Response.Write("<script>window.alert('查看结果不存在！');</script>");
            }
        }
        protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
        {
             Bind2();
        }

        protected void LinkButton1_Click(object sender, EventArgs e)
        {
            Bind1();
        }
    }
}